#include<iostream>
using namespace std;

#include<unistd.h>
#include<sys/types.h>

int main()
{
    pid_t ret=fork();
    if(ret==0)
    {
       // int n=10;
        while(1)
        {
            cout<<"我是子进程，PID:"<<getpid()<<" PPID:"<<getppid()<<endl;
            sleep(1);
        }
    }

   else if(ret>0)
    {
        while(1)
        {
            cout<<"我是父进程，PID:"<<getpid()<<" PPID:"<<getppid()<<endl;
            sleep(1);
        }
    }
   else 
   {
       while(1)
       {
           cout<<"Make son process fail"<<endl;
           sleep(1);
       }
   }

   // while(1)
   // {
   //     cout<<"I'm a process,my PID is:"<<getpid()<<endl;
   //     sleep(1);
   // }
    return 0;
}
